<?

if($action != ACTION_SAVE_ORGAN) {
	$a_clovek_id = $_GET['id_clen'];
	if($a_clovek_id != "") {
	  $query = getClen($a_clovek_id);
	  $fetch = MySQL_Fetch_Array($query);
	  $a_clovek_name = $fetch["JMENO"];
	  $a_clovek_function = $fetch["FUNKCE"];
	  $a_clovek_priority = $fetch["PRIORITA"];
	  $a_clovek_photo = $fetch["FOTO"];
	} else {
	  $a_clovek_name = "";
	  $a_clovek_function = "";
	  $a_clovek_priority = 1;
	  $a_clovek_photo = "";
}
}

if ($handle = opendir('./img/lide')) {
  while ($file = readdir($handle)){
      $polozky[count($polozky)] = $file;
  }
  closedir($handle);
  sort($polozky);
}

reset($polozky);

$pripony = array ("bmp", "jpg", "png", "gif");

?>

<form action="<? echo redirect_str(PAGE_ADMIN_MANAGEMENT).action(ACTION_SAVE_ORGAN); ?>" method="post">
  
  <input type="hidden" name="a_clovek_id" value="<? echo $a_clovek_id;?>">
  
  <fieldset>
    <legend><? echo ($a_clovek_id!=""?"úprava člena":"nový člen"); ?></legend>
    
    <table class="panel-70">
      <tr>
        <td class="righted">jméno <span class="star">*</span></td>
        <td><input class='text px120' type='text' name="a_clovek_name" value="<? echo $a_clovek_name;?>"></td>
      </tr>
      
      <tr>
        <td class="righted">funkce <span class="star">*</span></td>
        <td><input class='text px120' type='text' name="a_clovek_function" value="<? echo $a_clovek_function;?>"></td>
      </tr>
      
      <tr>
        <td class="righted">priorita <span class="star">*</span></td>
        <td>
          <select class="text" name='a_clovek_priority' size=1>
          <?
          for($i=1; $i<10; $i++){
            if($a_clovek_priority == $i) echo "<option value='$i' selected>$i</option>";
            else echo "<option value='$i'>$i</option>";
          }
          ?>
          </select>
        </td>
      </tr>
      
      <tr>
        <td class="righted">foto</td>
        <td>
          <select class="text" name='a_clovek_photo' size=1>
            <option value="">není</option>
            <?
            while (list($key, $val) = each($polozky)) {
              $str = explode (".", $val);
              if ($val != "." && $val != ".." && in_array($str[1], $pripony)) {
                  if (!is_dir($val)) {
                    if($val == $a_clovek_photo)  echo "<option value='$val' selected>$val</option>";
                    else echo "<option value='$val'>$val</option>";
                  }
               }
            }
            ?>
          </select>
        </td>
      </tr>
      
      <tr>
        <td colspan="2">
        <div class="center">
            <input class="button" onmouseover="this.className='button_hover'" 
       			onmouseout="this.className='button'" type="submit" value="ULOŽIT">
       		<a class="button preloader" href="<? echo redirect_str(PAGE_ADMIN_MANAGEMENT); ?>">ZRUŠIT</a>
        </div>
        </td>
      </tr>
      
    </table>
  </fieldset>
</form>
